package com.gxwy.shenzhou.message;

import com.gxwy.shenzhou.HeaderRequest;
import com.gxwy.shenzhou.SplitString;
import com.gxwy.shenzhou.StringHandler;
import com.gxwy.shenzhou.Supply;

public class ZhengCunZhengQuXiaoZhuanHuHuoQiResponse implements StringHandler{
   private String zhdh;
   private String khxm;
   private String zhye;
   private String lx;
   private String bzlx;
   private String khrq;
   private String qxrq;
   private String dqrq;
   private String cq;
   private String zysm;
   private String xm;
   private String xgzh;
   private String bcje;
   private String bbye;
   private String lxs;
   private String ljlxs;
  
   private static final int ZHDH_LEN=32;
   private static final int KHXM_LEN=60;
   private static final int ZHYE_LEN=15;
   private static final int LX_LEN=15;
   private static final int BZLX_LEN=15;
   private static final int KHRQ_LEN=8;
   private static final int QXRQ_LEN=8;
   private static final int DQRQ_LEN=8;
   private static final int CQ_LEN=3;
   private static final int ZYSM_LEN=30;
   private static final int XM_LEN=60;
   private static final int XGZH_LEN=32;
   private static final int BCJE_LEN=15;
   private static final int BBYE_LEN=15;
   
   private static final int LXS_LEN=15;
   
   
   
   private static final int LJLXS_LEN=15;
   
   
   
   
   public static final int TOTAL=ZHDH_LEN+KHXM_LEN+ZHYE_LEN+LX_LEN+BZLX_LEN+KHRQ_LEN+QXRQ_LEN+DQRQ_LEN+
		   CQ_LEN+ZYSM_LEN+XM_LEN+XGZH_LEN+BCJE_LEN+BBYE_LEN+LXS_LEN+
		   LJLXS_LEN;
   private int reallon=0;
   private static final int ZHDH_FLAG=1;
   private static final int KHXM_FLAG=1;
   private static final int ZHYE_FLAG=1;
   private static final int LX_FLAG=1;
   private static final int BZLX_FLAG=1;
   private static final int KHRQ_FLAG=1;
   private static final int QXRQ_FLAG=1;
   private static final int DQRQ_FLAG=1;
   private static final int CQ_FLAG=1;
   private static final int ZYSM_FLAG=1;
   private static final int XM_FLAG=1;
   private static final int XGZH_FLAG=1;
   private static final int BCJE_FLAG=1;
   private static final int BBYE_FLAG=1;
   private static final int LXS_FLAG=1;
   
   
   
   private static final int LJLXS_FLAG=1;

   private HeaderRequest header=new HeaderRequest(true);
/**
/**
 * @return the zhdh
 */

public String getZhdh() {
	return zhdh;
}
public HeaderRequest getHeader() {
	return header;
}
public void setHeader(HeaderRequest header) {
	this.header = header;
}
/**
 * @param zhdh the zhdh to set
 */
public void setZhdh(String zhdh) throws Exception{
	if(zhdh==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(zhdh.getBytes("gbk").length<ZHDH_LEN){
		this.zhdh=Supply.supply(zhdh,ZHDH_FLAG,ZHDH_LEN);;
	}else if(zhdh.getBytes("gbk").length>ZHDH_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.zhdh = zhdh;			
	}
}
/**
 * @return the khxm
 */
public String getKhxm() {
	return khxm;
}
/**
 * @param khxm the khxm to set
 */
public void setKhxm(String khxm) throws Exception{
	if(khxm==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(khxm.getBytes("gbk").length<KHXM_LEN){

		this.khxm=Supply.supply(khxm,KHXM_FLAG,KHXM_LEN);
	}else if(khxm.getBytes("gbk").length>KHXM_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.khxm = khxm;			
	}
}
/**
 * @return the zhye
 */
public String getZhye() {
	return zhye;
}
/**
 * @param zhye the zhye to set
 */
public void setZhye(String zhye) throws Exception{
	if(zhye==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(zhye.getBytes("gbk").length<ZHYE_LEN){
	
		this.zhye=Supply.supply(zhye,ZHYE_FLAG,ZHYE_LEN);
	}else if(zhye.getBytes("gbk").length>ZHYE_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.zhye = zhye;			
	}
}

public String getLx() {
	return lx;
}
/**
 * @param lx the lx to set
 */
public void setLx(String lx) throws Exception{
	if(lx==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(lx.getBytes("gbk").length<LX_LEN){

		this.lx=Supply.supply(lx,LX_FLAG,LX_LEN);
	}else if(lx.getBytes("gbk").length>LX_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.lx = lx;			
	}
}
/**
 * @return the bzlx
 */
public String getBzlx() {
	return bzlx;
}
/**
 * @param bzlx the bzlx to set
 */
public void setBzlx(String bzlx) throws Exception{
	if(bzlx==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(bzlx.getBytes("gbk").length<BZLX_LEN){
	
		this.bzlx=Supply.supply(bzlx,BZLX_FLAG,BZLX_LEN);
	}else if(bzlx.getBytes("gbk").length>BZLX_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.bzlx = bzlx;			
	}
}
/**
 * @return the khrq
 */
public String getKhrq() {
	return khrq;
}
/**
 * @param khrq the khrq to set
 */
public void setKhrq(String khrq) throws Exception{
	if(khrq==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(khrq.getBytes("gbk").length<KHRQ_LEN){
	
		this.khrq=Supply.supply(khrq,KHRQ_FLAG,KHRQ_LEN);
	}else if(khrq.getBytes("gbk").length>KHRQ_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.khrq = khrq;			
	}
}
/**
 * @return the qxrq
 */
public String getQxrq() {
	return qxrq;
}
/**
 * @param qxrq the qxrq to set
 */
public void setQxrq(String qxrq)  throws Exception{
	if(qxrq==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(qxrq.getBytes("gbk").length<QXRQ_LEN){
	
		this.qxrq=Supply.supply(qxrq,QXRQ_FLAG,QXRQ_LEN);
;
	}else if(qxrq.getBytes("gbk").length>QXRQ_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.qxrq = qxrq;			
	}
}
/**
 * @return the dqrq
 */
public String getDqrq() {
	return dqrq;
}
/**
 * @param dqrq the dqrq to set
 */
public void setDqrq(String dqrq) throws Exception{
	if(dqrq==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(dqrq.getBytes("gbk").length<DQRQ_LEN){
		this.dqrq=Supply.supply(dqrq,DQRQ_FLAG,DQRQ_LEN);

	}else if(dqrq.getBytes("gbk").length>DQRQ_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.dqrq = dqrq;			
	}
}
/**
 * @return the cq
 */
public String getCq() {
	return cq;
}
/**
 * @param cq the cq to set
 */
public void setCq(String cq) throws Exception{
	if(cq==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(cq.getBytes("gbk").length<CQ_LEN){
	
		this.cq=Supply.supply(cq,CQ_FLAG,CQ_LEN);
	}else if(cq.getBytes("gbk").length>CQ_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.cq = cq;			
	}
}
/**
 * @return the zysm
 */
public String getZysm() {
	return zysm;
}
/**
 * @param zysm the zysm to set
 */
public void setZysm(String zysm) throws Exception{
	if(zysm==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(zysm.getBytes("gbk").length<ZYSM_LEN){

		this.zysm=Supply.supply(zysm,ZYSM_FLAG,ZYSM_LEN);
	}else if(zysm.getBytes("gbk").length>ZYSM_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.zysm = zysm;			
	}
}
/**
 * @return the xm
 */
public String getXm() {
	return xm;
}
/**
 * @param xm the xm to set
 */
public void setXm(String xm) throws Exception{
	if(xm==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(xm.getBytes("gbk").length<XM_LEN){

		this.xm=Supply.supply(xm,XM_FLAG,XM_LEN);
	}else if(xm.getBytes("gbk").length>XM_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.xm = xm;			
	}
}
/**
 * @return the xgzh
 */
public String getXgzh() {
	return xgzh;
}

public void setXgzh(String xgzh) throws Exception{
	if(xgzh==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(xgzh.getBytes("gbk").length<XGZH_LEN){
		
		this.xgzh=Supply.supply(xgzh,XGZH_FLAG,XGZH_LEN);;
	}else if(xgzh.getBytes("gbk").length>XGZH_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.xgzh = xgzh;			
	}
}

public String getBcje() {
	return bcje;
}
public void setBcje(String bcje) throws Exception {
	if(bcje==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(bcje.getBytes("gbk").length<BCJE_LEN){
		
		this.bcje=Supply.supply(bcje,BCJE_FLAG,BCJE_LEN);
		
	}else if(bcje.getBytes("gbk").length>BCJE_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.bcje = bcje;			
	}
}
public String getBbye() {
	return bbye;
}
public void setBbye(String bbye) throws Exception {
	if(bbye==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(bbye.getBytes("gbk").length<BBYE_LEN){
		
		this.bbye=Supply.supply(bbye,BBYE_FLAG,BBYE_LEN);;
	}else if(bbye.getBytes("gbk").length>BBYE_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.bbye = bbye;			
	}
}
public String getLxs() {
	return lxs;
}
public void setLxs(String lxs) throws Exception {
	if(lxs==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(lxs.getBytes("gbk").length<LXS_LEN){
		
		this.lxs=Supply.supply(lxs,LXS_FLAG,LXS_LEN);;
	}else if(lxs.getBytes("gbk").length>LXS_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.lxs = lxs;			
	}
}



public String getLjlxs() {
	return ljlxs;
}
public void setLjlxs(String ljlxs) throws Exception {
	if(ljlxs==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(ljlxs.getBytes("gbk").length<LJLXS_LEN){
		
		this.ljlxs=Supply.supply(ljlxs,LJLXS_FLAG,LJLXS_LEN);;
	}else if(ljlxs.getBytes("gbk").length>LJLXS_LEN){
		 Exception e=new Exception("Too Long");
		 throw e;
	}else{
		this.ljlxs = ljlxs;			
	}
}
public String build () throws Exception{
	if(this.getHeader()==null){
		throw new Exception("Header is null");
	}

	if(this.getZhdh()==null){
		this.setZhdh("");
	}
	if(this.getKhxm()==null){
		this.setKhxm("");
	}
	if(this.getZhye()==null){
		this.setZhye("");
	}
	if(this.getLx()==null){
		this.setLx("");
	}
	if(this.getBzlx()==null){
		this.setBzlx("");
	}
	if(this.getKhrq()==null){
		this.setKhrq("");
	}
	if(this.getQxrq()==null){
		this.setQxrq("");
	}
	if(this.getDqrq()==null){
		this.setDqrq("");
	}
	if(this.getCq()==null){
		this.setCq("");
	}
	if(this.getZysm()==null){
		this.setZysm("");
	}
	if(this.getXm()==null){
		this.setXm("");
	}
	if(this.getXgzh()==null){
		this.setXgzh("");
	}   
	if(this.getBcje()==null){
		this.setBcje("");
	}   
	if(this.getBbye()==null){
		this.setBbye("");
	}   
	if(this.getLxs()==null){
		this.setLxs("");
	}   
	if(this.getLjlxs()==null){
		this.setLjlxs("");
	}   
	Integer totallen=header.TOTAL_LEN+TOTAL-HeaderRequest.LEN_LEN;
    this.getHeader().setLen(totallen.toString());
    return 
		   this.getHeader().build()+ this.getZhdh()+
		  this.getKhxm()+
		  this.getZhye()+
		  this.getLx()+
		  this.getBzlx()+
		  this.getKhrq()+
		  this.getQxrq()+
		  this.getDqrq()+
     	  this.getCq()+
          this.getZysm()+
           this.getXm()+
	       this.getXgzh()+
	      this.getBcje()+
	      this.getBbye()+
          this.getLxs()+
	        this.getLjlxs();
		}
public void parse(String str) throws Exception{
	if(str==null){
		Exception e=new Exception("String is null");
		throw e;
	}else if(str.getBytes("gbk").length<header.TOTAL_LEN+TOTAL){
		Exception e=new Exception("Invalid request");
		throw e;
	}else{
		String headerLen=SplitString.splitString(str,reallon, reallon+header.TOTAL_LEN);
		reallon+=header.TOTAL_LEN;
		header.parse(headerLen);				
		this.setZhdh(SplitString.splitString(str,reallon,reallon+ZHDH_LEN));
		reallon+=ZHDH_LEN;
		this.setKhxm(SplitString.splitString(str,reallon,reallon+KHXM_LEN));
		reallon+=KHXM_LEN;
	     this.setZhye(SplitString.splitString(str,reallon,reallon+ZHYE_LEN));
	    reallon+=ZHYE_LEN;
	     this.setLx(SplitString.splitString(str,reallon,reallon+LX_LEN));
	     reallon+=LX_LEN;
	     this.setBzlx(SplitString.splitString(str,reallon,reallon+BZLX_LEN));
	     reallon+=BZLX_LEN;
	     this.setKhrq(SplitString.splitString(str,reallon,reallon+KHRQ_LEN));
	     reallon+=KHRQ_LEN;
	     this.setQxrq(SplitString.splitString(str,reallon,reallon+QXRQ_LEN));
	     reallon+=QXRQ_LEN;
	     this.setDqrq(SplitString.splitString(str,reallon,reallon+DQRQ_LEN));
	     reallon+=DQRQ_LEN;
	     this.setCq(SplitString.splitString(str,reallon,reallon+CQ_LEN));
	     reallon+=CQ_LEN;
	     this.setZysm(SplitString.splitString(str,reallon,reallon+ZYSM_LEN));
	     reallon+=ZYSM_LEN;
	     this.setXm(SplitString.splitString(str,reallon,reallon+XM_LEN));
	     reallon+=XM_LEN;
	     this.setXgzh(SplitString.splitString(str,reallon,reallon+XGZH_LEN));
	     reallon+=XGZH_LEN;
	     this.setBcje(SplitString.splitString(str,reallon,reallon+BCJE_LEN));
	     reallon+=BCJE_LEN;
	     this.setBbye(SplitString.splitString(str,reallon,reallon+BBYE_LEN));
         reallon+=BBYE_LEN;
         this.setLxs(SplitString.splitString(str,reallon,reallon+LXS_LEN));
         reallon+=LXS_LEN;
         this.setLjlxs(SplitString.splitString(str,reallon,reallon+LJLXS_LEN));
	}

}
public static void main(String args[]) throws Exception{
	ZhengCunZhengQuXiaoZhuanHuHuoQiResponse a=new ZhengCunZhengQuXiaoZhuanHuHuoQiResponse();
	a.setZhdh("3");
	a.setKhxm("1");
	a.setZhye("4");
	a.setLx("9");
    a.setBcje("1");
   a.parse(a.build());
   if(a.getZhdh().trim().equals("3")){
	   System.out.print("zhdhyes");
   }
   if(a.getKhxm().trim().equals("1")){
	   System.out.println("khxmyes");
   }
   if(a.getZhye().trim().equals("4")){
	   System.out.println("zhyeyes");
   }
   if(a.getLx().trim().equals("9")){
	   System.out.println("lxyes");
   }
   if(a.getBcje().trim().equals("1")){
	   System.out.println("Bcjeyes");
   }
//   System.out.println(a.getZhdh());
//   System.out.println(a.getKhxm());
//   System.out.println(a.getZhye());
//  System.out.println(a.getLx());
//  System.out.println(a.getBcje());
  
  
}
   
}
